<?php
	include_once('../db.php');
	$db=new DB();
	$sql="select name from nav";
	$list=$db->get($sql);
?>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>后台欢迎页</title>
	<link rel="stylesheet" href="../css/reset.css" />
	<link rel="stylesheet" href="../css/public.css" />
	<link rel="stylesheet" href="../css/content.css" />
	<script src="../js/laydate.js"></script>
</head>
<body marginwidth="0" marginheight="0">
	<div class="container">
		<div class="public-nav">您当前的位置：<a href=" ">文章添加</a>></div>
		<div class="public-content">
			<div class="public-content-header">
				<h3>添加文章</h3>
			</div>
			<div class="public-content-cont">
			<form action="" method="post">
				<div class="form-group">
					<label for="">信息标题</label>
					<input class="form-input-txt" type="text" name="title" value="" />
					<input class="form-input-radius" type="checkbox" name="status" value="0" />已通过
					<input class="form-input-radius" type="checkbox" name="status" value="1" />未通过
				</div>
				<div class="form-group">
					<label for="">录入时间</label>
					<input class="form-input-txt" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})"
					name="create_time">
				</div>
				
				<div class="form-group">
					<textarea id="editor_id" name="content"  class="form-input-textara" style="width:700px;height:300px;"></textarea> 
				</div>
				<div class="form-group">
				<label>所属菜单</label>
					<select name="menu" style="width: 350px;height:35px;border-radius:8px;">
					<?php
					for ($i=0; $i <count($list);$i++) {
					    $nav=$list[$i][0]; 
					 	?>
					 	<option value="<?php echo $nav?>" checked><?php echo$nav ?></option>
					 <?php
					 } 
					 ?>
					 </select>
				</div>	
				
				
				<div class="form-group" style="margin-left:150px;">
					<input type="submit" class="sub-btn" value="提  交" name="submit" />
					<input type="reset" class="sub-btn" value="重  置" name="reset" />
				</div>
				</form>
			</div>
		</div>
	</div>
<script src="../kingediter/kindeditor-all-min.js"></script>
<script src="../js/laydate.js"></script>
<script>
	 KindEditor.ready(function(K) {
                window.editor = K.create('#editor_id');
        });
</script>
</body>
</html>
<?php 
    include "article.php";
    if (isset($_POST['submit'])) {      
        if (empty($_POST['title']||$_POST['content']||$_POST['author']||$_POST['status']||$_POST['create_time'])) {
            echo "相关数据不能为空";
        }else{
            $arr = array();
        $id=null;
        $arr['title'] = $_POST['title'];
        $arr['content'] = htmlspecialchars($_POST['content'],ENT_COMPAT,'UTF-8');
        $arr['menu']=$_POST['menu'];
        $arr['status']=$_POST['status'];
        $arr['create_time'] =strtotime($_POST['create_time']);
            $msg = new Msg();
            $res =$msg->add($arr,$id);
        }      
    } else{
    	if (isset($_POST['reset'])) {
    		header("location:article_add.php");
    }
}
 ?>
                  